"""

Rewrite torch.utils.data.Dataset for TextCNN.

"""

import numpy as np
import torch.utils.data as Data

        
class TextDataset(Data.Dataset):
    
    def __init__(self, x):
        """
       Initialize our dataset class.

       Args:
       - x: :list: list of tuples that is our dataset.
        """
        super().__init__()
        self.dataset = x
    
    def __getitem__(self, idx):
        return self.dataset[idx][0], self.dataset[idx][1]
    
    def __len__(self):
        return len(self.dataset)